package com.sgb.auction.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sgb.auction.BR;
import com.sgb.auction.R;
import com.sgb.auction.entity.PublishListBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * Time:2021/9/6
 * AUTHOR:F_Q
 * Description:
 */
public class SourcesFundAdapter extends BaseRecycleAdapter<PublishListBean> {

    public SourcesFundAdapter(Context context, List<PublishListBean> datas) {
        super(context, R.layout.pm_item_sourcesfund, datas);
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, @SuppressLint("RecyclerView") int position) {
        super.onBindViewHolder(holder, position);
        RelativeLayout rl_item = holder.itemView.findViewById(R.id.rl_item);
        TextView labelname_tv = holder.itemView.findViewById(R.id.labelname_tv);
        rl_item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean selected = datas.get(position).isSelected();
                datas.get(position).setSelected(!selected);
                notifyDataSetChanged();
            }
        });
        labelname_tv.setSelected(datas.get(position).isSelected());
    }

    @Override
    public void convert(ItemViewHolder holder, PublishListBean bean) {
        holder.setBinding(BR.viewModel, bean);
    }
}
